import Vue from 'vue'
import Router from 'vue-router'
import SecondPage from '@/components/pc/secondPage'
const LoginIndex = () => import('pc_views/login/Index.vue')
const Login = () => import('pc_views/login/Login.vue')
const Register = () => import('pc_views/login/Register.vue')
// import MinePC from '@/components/pc/MinePC'

Vue.use(Router)

let router = new Router({
  routes: [
    {
      path: '/',
      name: 'LoginIndex',
      component: LoginIndex,
      children: [
        {
          path: '/',
          redirect: '/login'
        },
        {
          path: '/login',
          name: 'login',
          component: Login
        },
        {
          path: '/register',
          name: 'register',
          component: Register
        }
      ]
    },
    {
      path: '/secondPage',
      name: 'secondPage',
      component: SecondPage
    }
    // {
    //   path: '/minePc',
    //   name: 'minePc',
    //   component: MinePC
    // }
  ]
})

/**
 * 判断是否为移动设备，是，则跳转到移动端的路径
 */
router.beforeEach((to, from, next) => {
  if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
    window.location.href = '/m_index.html#/'
    return
  }
  next()
})

export default router
